Conclusion.js ➔ describe(ꞌConclusionꞌ)   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 121

Duplication

Lines 121
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 0
dl 121
loc 121
rs 8.2857

4 Functions

Rating   Name   Duplication   Size   Complexity  
B Conclusion.js ➔ ... ➔ it(ꞌBuildꞌ) 25 25 1
B Conclusion.js ➔ ... ➔ it(ꞌCreate with mixed dataꞌ) 26 26 1
B Conclusion.js ➔ ... ➔ it(ꞌtoJSONꞌ) 27 27 1
B Conclusion.js ➔ ... ➔ it(ꞌCreate with JSONꞌ) 36 36 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1 View Code Duplication
var assert = require('chai').assert,
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
    GedcomX = require('../../');
3
4
describe('Conclusion', function(){
5
  
6
  it('Create with JSON', function(){
7
    var conclusion = GedcomX.Conclusion({
8
      id: 'conclusion',
9
      lang: 'en',
10
      sortKey: '149das',
11
      analysis: {
12
        resource: 'http://analysis/uri'
13
      },
14
      confidence: 'http://gedcomx.org/High',
15
      attribution: {
16
        created: 1145667891
17
      },
18
      sources: [
19
        {
20
          description: 'http://description/uri'
21
        }  
22
      ],
23
      notes: [
24
        {
25
          subject: 'Note title',
26
          text: 'Note text'
27
        }
28
      ]
29
    });
30
    assert.equal(conclusion.getId(), 'conclusion');
31
    assert.equal(conclusion.getLang(), 'en');
32
    assert.equal(conclusion.getSortKey(), '149das');
33
    assert.equal(conclusion.getAnalysis().getResource(), 'http://analysis/uri');
34
    assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High');
35
    assert.equal(conclusion.getAttribution().getCreated().getTime(), 1145667891);
36
    assert.equal(conclusion.getSources().length, 1);
37
    assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri');
38
    assert.equal(conclusion.getNotes().length, 1);
39
    assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title');
40
    assert.equal(conclusion.getNotes()[0].getText(), 'Note text');
41
  });
42
  
43
  it('Create with mixed data', function(){
44
    var conclusion = GedcomX.Conclusion({
45
      id: 'conclusion',
46
      lang: 'en',
47
      sortKey: '149das',
48
      confidence: 'http://gedcomx.org/High',
49
      sources: [
50
        GedcomX.SourceReference({ description: 'http://description/uri' })
51
      ],
52
      notes: [
53
        GedcomX.Note({
54
          subject: 'Note title',
55
          text: 'Note text'
56
        })
57
      ]
58
    });
59
    assert.equal(conclusion.getId(), 'conclusion');
60
    assert.equal(conclusion.getLang(), 'en');
61
    assert.equal(conclusion.getSortKey(), '149das');
62
    assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High');
63
    assert.equal(conclusion.getSources().length, 1);
64
    assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri');
65
    assert.equal(conclusion.getNotes().length, 1);
66
    assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title');
67
    assert.equal(conclusion.getNotes()[0].getText(), 'Note text');
68
  });
69
  
70
  it('Build', function(){
71
    var conclusion = GedcomX.Conclusion()
72
      .setId('conclusion')
73
      .setLang('en')
74
      .setSortKey('149das')
75
      .setConfidence('http://gedcomx.org/High')
76
      .addSource(
77
        GedcomX.SourceReference()
78
          .setDescription('http://description/uri')
79
      )
80
      .addNote(
81
        GedcomX.Note()
82
          .setSubject('Note title')
83
          .setText('Note text')
84
      );
85
    assert.equal(conclusion.getId(), 'conclusion');
86
    assert.equal(conclusion.getLang(), 'en');
87
    assert.equal(conclusion.getSortKey(), '149das');
88
    assert.equal(conclusion.getConfidence(), 'http://gedcomx.org/High');
89
    assert.equal(conclusion.getSources().length, 1);
90
    assert.equal(conclusion.getSources()[0].getDescription(), 'http://description/uri');
91
    assert.equal(conclusion.getNotes().length, 1);
92
    assert.equal(conclusion.getNotes()[0].getSubject(), 'Note title');
93
    assert.equal(conclusion.getNotes()[0].getText(), 'Note text');
94
  });
95
  
96
  it('toJSON', function(){
97
    var data = {
98
      id: 'conclusion',
99
      lang: 'en',
100
      sortKey: '149das',
101
      analysis: {
102
        resource: 'http://analysis/uri'
103
      },
104
      confidence: 'http://gedcomx.org/High',
105
      attribution: {
106
        created: 1145667891
107
      },
108
      sources: [
109
        {
110
          description: 'http://description/uri'
111
        }  
112
      ],
113
      notes: [
114
        {
115
          subject: 'Note title',
116
          text: 'Note text'
117
        }
118
      ]
119
    },
120
    conclusion = GedcomX.Conclusion(data);
121
    assert.deepEqual(conclusion.toJSON(), data);
122
  });
123
  
124
});